home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / CustomSolutionWizard_Files / Examples / VCPPExample / VCPPExample.cpp next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  1.3 KB  |  58 lines

  1. #include <iostream>
  2. #include "VCPPExample.h"
  3.  
  4. enum {NSRecallNetwork, NSLearningNetwork};
  5.  
  6. int main()
  7. {
  8.     HINSTANCE hDLL = LoadDLLFunctions("C:\\Program Files\\NeuroSolutions 4\\Wizards\\CustomSolutionWizard\\Examples\\DLL\\MLP.dll");
  9.     if (hDLL)
  10.     {
  11.         float *inputData = new float[8];
  12.         inputData[0] = -1;
  13.         inputData[1] = -1;
  14.         inputData[2] = -1;
  15.         inputData[3] = 1;
  16.         inputData[4] = 1;
  17.         inputData[5] = -1;
  18.         inputData[6] = 1;
  19.         inputData[7] = 1;
  20.  
  21.         float *desiredData = new float[4];
  22.         desiredData[0] = -1;
  23.         desiredData[1] = 1;
  24.         desiredData[2] = 1;
  25.         desiredData[3] = -1;
  26.  
  27.         void *nn;
  28.         createNetwork(nn, NSLearningNetwork);
  29.  
  30.         loadWeights(nn,"C:\\Program Files\\NeuroSolutions 4\\Wizards\\CustomSolutionWizard\\Examples\\DLL\\MLP.nsw");
  31.  
  32.         std::cout << "Epochs: ";
  33.         int epochs;
  34.         std::cin >> epochs;
  35.  
  36.         train(nn, epochs, 4, inputData, desiredData, 0, NULL, NULL);
  37.  
  38.         float *outputData = new float[4];
  39.         getResponse(nn, 4, inputData, outputData);
  40.  
  41.         std::cout << "\nNetwork Output\n";
  42.         for (int i = 0; i < 4; i++)
  43.         std::cout << outputData[i] << "\n";
  44.  
  45.         delete inputData;
  46.         delete desiredData;
  47.         destroyNetwork(nn);
  48.         FreeLibrary(hDLL);
  49.     }
  50.     else
  51.         std::cout << "ERROR LOADING DLL";
  52.  
  53.     std::cout << "\n\nType any character then click Enter to exit!\n";
  54.     char aChar;
  55.     std::cin >> aChar;
  56.  
  57.     return 0;
  58. }